package com.gxa.controller.monthgoals;


import com.gxa.common.JsonResult;
import com.gxa.common.R;
import com.gxa.pojo.goalPojo.GoalPojo;
import com.gxa.service.MonthGoalService;
import com.gxa.utils.DateUtils;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Controller
@RequestMapping("/edit_goal")
@Api(value = "填写月度目标页面",tags = "填写月度目标页接口")
public class EditMonthGoal {

    @Autowired
    private MonthGoalService monthGoalService;

    @RequestMapping(value = "/queryGoal",method = RequestMethod.POST)
    @ApiOperation(value = "查询月度目标接口",notes = "传递用户名称",httpMethod = "POST", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R findTiltle(String emp_name){


     return monthGoalService.FindTitles(emp_name);
    }


    @RequestMapping(value = "/updateGoal",method = RequestMethod.POST)
    @ApiOperation(value = "添加月度目标接口",notes = "传递表头信息",httpMethod = "POST", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R editGoals(@RequestBody GoalPojo goalPojo){
        System.out.println("添加月度目标接口");
        System.out.println("添加月度目标接口");
        System.out.println("添加月度目标接口");
        System.out.println("添加月度目标接口");
        System.out.println("添加月度目标接口");
        System.out.println(goalPojo.toString());
        Date time= DateUtils.string2Date(DateUtils.getCurrentTime("yyyy-MM-dd"));
        return monthGoalService.EidtTitles(goalPojo,time);
    }
}
